package com.starblink.login.changeboundemail.verifyemail.ui

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.starblink.android.basic.base.BaseViewModel
import com.starblink.android.basic.ext.toast
import com.starblink.android.basic.network.base.SkGqlClient
import com.starblink.basic.util.ActivityStackManage
import com.starblink.basic.util.log.YYLogUtils
import com.starblink.rocketreserver.UpdateEmailMutation
import kotlinx.coroutines.launch

class ChangeBoundEmailVerifyEmailVM : BaseViewModel() {
    fun updateEmail(email: String) {
        viewModelScope.launch {
            val response = SkGqlClient.skMutation(
                UpdateEmailMutation(email = email),
                showDefaultLoading = true
            )
            if (response?.data != null) {
                YYLogUtils.e("updateEmail=${response.data!!.updateEmail}", "dss")
                toast("Your email address has been verified. ")
                // 返回MainActivity
                ActivityStackManage.toMainActivity()
            }
        }
    }
}